package com.ds.infrastructure.audit.collector.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

/**
 * 作用：
 *
 * @author WeiShaoying
 * @date 2020/8/11
 */
@RestController
public class IndexController {

    private static final Logger elkLogger = LoggerFactory.getLogger("elk");

    private static final String UP_STATUS = "{\"status\":\"UP\"}";

    private static final String MSG = "Hello, Audit collector";

    @GetMapping("/")
    public String index() {
        return MSG;
    }

    private Random random = new Random();

    @GetMapping("/health")
    public String health() {
        elkLogger.info("{}$${}$${}$${}$${}", "Collector", "WSY", System.currentTimeMillis(), "TEST", random.nextInt(10000));
        return UP_STATUS;
    }
}
